package com.zr.WarehouseBelonging.dao;

import com.zr.WarehouseBelonging.pojo.*;
import com.zr.util.ResultVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * Created by Administrator on 2019/6/13.
 */
@Mapper
public interface WarehouseBelongingMapper {
    @Select("select * from legalperson where id =#{id}")
    Legalperson ByLegalPersonId(Integer id);

    @Select("select * from depot where depotCode =#{depotCode}")
    Depot queryByDepotCode(String depotCode);

    @Update("update Depot set status=#{status} where depotCode = #{depotCode}")
    int updateState(Depot depot);

    List<Depot> queryPage(DepotSelectVo depotSelectVo);
    int queryCount(DepotSelectVo depotSelectVo);

    @Select("select * from depot where legalPersonId #={legalPersonId}")
    Depot queryDepot(Integer legalPersonId);
    @Select("select * from depotarea where depotId #={depotId}")
    Depotarea queryDepotarea(Integer depotId);
    @Select("select * from depotposition where depotareaId #={depotareaId}")
    List<Depotposition> queryDepotposition(Integer depotareaId);

    List<Depot> queryPageDepot(DepotSelectVo depotSelectVo);

    List<Integer> queryDepotById(@RequestBody  List<Integer> depotId);

    List<Integer> queryDepotareaById(@RequestBody  List<Integer> depotareaId);

    @Insert("insert into warehouse_belonging(legalpersonId,DepotpositionId) values(#{legalpersonId},#{DepotpositionId})")
    ResultVo addWarehouseBelonging(Integer legalpersonId,Integer DepotpositionId);

    @Select("select * from warehouse_belonging wb left join legalperson l on wb.legalpersonId = l.id")
    Legalperson queryLegalPerson(Integer legalpersonId);
}
